<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
  <script src="js/jquery-3.6.0.js"></script>

</head>
<body>
请输入 userId 的值 <input type="text" id="userId" />
<br />
请输入 classId 的值 <input type="text" id="classId" />
<br />
<button id="submit">以POST的方式提交JSON格式数据</button>
</body>
<script>
		let userIdInput = document.querySelector("#userId");
		let classIdInput = document.querySelector("#classId");
		let submit = document.querySelector("#submit");
		submit.onclick = function() {
			$.ajax({
				type: 'post',
				url: '2507_json',
				data: JSON.stringify({
					userId: userIdInput.value,
					classId: classIdInput.value
				}),
				contentType: 'application/json; utf-8',
				success: function(body) {
					console.log(body);
				}
			})
		}
	</script>
</html>